#ifndef DIALOGVIDEOSETUP_H
#define DIALOGVIDEOSETUP_H

#include <QDialog>
#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QCameraInfo>
#include <QCameraFocus>
#include <QException>
#include <QString>
#include <QTimer>

#include "WidgetVideo.h"

#define MAX_WIDTH   1920
#define MIN_WIDTH   320

namespace Ui {
class DialogVideoSetup;
}

class DialogVideoSetup : public QDialog
{
    Q_OBJECT

public:
    explicit DialogVideoSetup(QWidget *parent = nullptr);
    ~DialogVideoSetup();

    void setCamera(WidgetVideo *widgetVideo, QWidget *wtVideo);

private slots:
    void on_cbCameraInfo_currentIndexChanged(int index);

    void on_btnOpticalMinus_clicked();

    void on_btnOpticalPlus_clicked();

    void on_btnDigitalMinus_clicked();

    void on_btnDigitalPlus_clicked();

    void on_btnWinMinus_clicked();

    void on_btnWinPlus_clicked();

    void on_cbCameraList_currentIndexChanged(int index);

private:
    Ui::DialogVideoSetup *ui;

    bool isFirstEntry = true;

    int autoRepeatDelay = 500;
    int autoRepeatInterval = 200;

    qreal optical = 1.0;
    qreal digital = 1.0;

    qreal opticalMax = 1.0;
    qreal digitalMax = 1.0;

    QWidget *wtVideo;
    QCamera *camera = NULL;
    QCameraFocus *focus = NULL;

    QList<QCameraInfo> cameras;

    QList<QCameraViewfinderSettings> viewSets;

    WidgetVideo *widgetVideo;

    void initCamera();
    void getCameraList();
    void getCameraInfo();
    void setWidgetVideoGeometry(int w, int h);
};

#endif // DIALOGVIDEOSETUP_H
